/* 
 * File:   maininventory.cpp
 * Author: Reynald
 *
 * Created on March 21, 2011, 2:28 PM
 */

#include "classinventory.h"

using namespace std;

/*
 * 
 */
int main() {
    inventory I;
    long int uang = 10000;
    int pilih = 0;
    int amount = 0;
    int kodebar = 0;
    int slot = 0;
    I.ChangeMoney(uang);
    while (pilih != 10)
    {
        cout << "Welcome to driver Inventory" << endl;
        cout << "1.  Membeli barang" << endl;
        cout << "2.  Menjual barang" << endl;
        cout << "3.  Menampilkan isi inventory" << endl;
        cout << "4.  Tampil per slot" << endl;
        cout << "5.  Mengambil kode barang dari suatu slot" << endl;
        cout << "6.  Aktivasi Diskon" << endl;
        cout << "7.  Normalisasi Harga" << endl;
        cout << "8.  Cek Bibit/Bukan" << endl;
        cout << "9. Exit" << endl;
        cout << "Masukkan pilihan anda : ";
        cin >> pilih;
        switch(pilih)
        {
            case 1 :
            {
                     cout << "Uang anda sekarang : " << I.GetMoney() << endl;
                     cout << "Available slot : [0..2]" << endl;
                     cout << "List of item code : " << endl;
                     cout << "1.  bibit ChronoPlant" << endl;
                     cout << "2.  bibit ReynFruit" << endl;
                     cout << "3.  bibit Ichalmond" << endl;
                     cout << "4.  bibit Edondong" << endl;
                     cout << "5.  bibit GreenAlgoe" << endl;
                     cout << "6.  bibit Hanselnut" << endl;
                     cout << "7.  bibit AbelTree" << endl;
                     cout << "8.  bibit Elmonade" << endl;
                     cout << "9.  ChronoPlant(unbuyable)" << endl;
                     cout << "10. ReynFruit(unbuyable)" << endl;
                     cout << "11. Ichalmond(unbuyable)" << endl;
                     cout << "12. Edondong(unbuyable)" << endl;
                     cout << "13. GreenAlgoe(unbuyable)" << endl;
                     cout << "14. Hanselnut(unbuyable)" << endl;
                     cout << "15. AbelTree(unbuyable)" << endl;
                     cout << "16. Elmonade(unbuyable)" << endl;
                     cout << "0. Cancel" << endl;
                     cout << "Masukkan kode barang yang ingin anda beli : ";
                     cin >> kodebar;
                     if(kodebar != 0)
                     {
                         if(kodebar > 8)
                         {
                             cout << "Dibilangin unbuyable kok bandel?!" << endl;
                         }
                         else
                         {
                             cout << "Masukkan jumlah barang yang ingin anda beli : ";
                             cin >> amount;
                             I.Buy(kodebar,amount);
                         }
                     }
                     break;
            }
            case 2 :
            {
                     cout << "Masukkan slot dari inventory yang ingin anda jual(-999 untuk batal) : ";
                     cin >> slot;
                     if(slot != -999)
                     {
                         cout << "Masukkan jumlah barang yang ingin anda jual : ";
                         cin >> amount;
                         I.Sell(slot,amount);
                     }
                     cout << "Uang anda sekarang : " << I.GetMoney() << endl;
                     break;
            }
            case 3 :
            {
                     I.PrintInventory();
                     break;
            }
            case 4 :
            {
                     cout << "Masukkan nomor slot yang ingin anda lihat : ";
                     cin >> slot;
                     cout << "Isi dari slot ke-" << slot << "adalah" << I.GetInvent(slot).kodebarang << " , " << I.GetInvent(slot).amount << endl;
                     break;
            }
            case 5 :
            {
                     cout << "Masukkan nomor slot dari yang ingin anda lihat kode barangnya : ";
                     cin >> slot;
                     cout << "Kode barang dari slot ke-" << slot << " adalah : " << I.GetKodeBarang(slot) << endl;
                     break;
            }
            case 6 :
            {
                     I.Diskon50();
                     break;
            }
            case 7 :
            {
                     I.HargaNetral();
                     break;
            }
            case 8 :
            {
                     cout << "Masukkan nomor slot yang ingin anda cek : ";
                     cin >> slot;
                     if(I.IsBibit(slot) == 0)
                         cout << "Bukan Bibit" << endl;
                     else
                         cout << "Adalah Bibit" << endl;
                     break;
            }
            default :
            {
                break;
            }
        }
    }
    return 0;
}

